package com.vchello.controller.agency;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.vchello.bean.agency.Agency;
import com.vchello.controller.BaseController;
import com.vchello.service.agency.AgencyService;
import com.vchello.util.Utility;

/**
 * 
 * @author power
 *
 */
@Controller
@RequestMapping(value = "/agency")
public class AgencyController extends BaseController{
	
	@Autowired
	private AgencyService agencyService;
	
	@RequestMapping(value = "/apply", method = RequestMethod.GET)
	public String apply(){
		return "agency/apply";
		
	}
	
	@RequestMapping(value = "/apply", method = RequestMethod.POST)
	public void apply(Agency agency){
		if(null == agency){
			error("信息为空");
			return;
		}
		agency.setCreateTime(Utility.getSimpleFormatedDayNow());
		agency.setStatus(0);
		boolean isTrue = agencyService.insert(agency);
		if(isTrue){
			success("机构账号申请成功");
			return;
		}
		error("机构账号申请失败");
	}
}
